//
//  ItemView.m
//  Cat
//
//  Created by lushitong on 2018/12/22.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "ItemView.h"

@interface ItemView()

@property (nonatomic, strong) UIView *operView;
@property (nonatomic, strong) UILabel *nameLabel;

@end
@implementation ItemView

+ (CGSize)getSizeWithItemName:(NSString *)name {
	return CGSizeMake( [name getWidthWithFont:[UIFont systemFontOfSize:kQKFitFont(12)] height:MAXFLOAT] + kQKFitModuleDecimal(18.0), kQKFitModuleDecimal(28.0));
}

- (void)setItemString:(NSString *)itemString {
	self.nameLabel.text = itemString;
}

- (instancetype)initWithFrame:(CGRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		[self loadAllSubViews];
	}
	return self;
}

- (void)loadAllSubViews {
	[self addSubviews:@[self.operView,self.nameLabel]];
	
	[self.operView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.edges.equalTo(self);
	}];
	
	[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.center.equalTo(self.center);
	}];
}

#pragma mark----- lazy init -----

- (UIView *)operView {
	if (!_operView) {
		_operView = [[UIView alloc] init];
		_operView.backgroundColor = COLOR_WITH_HEX(0xF4F4F4);
	}
	return _operView;
}

- (UILabel *)nameLabel {
	if (!_nameLabel) {
		_nameLabel = [UILabel labelWithFont:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0x756D68)];
	}
	return _nameLabel;
}
@end
